package com.ctshk.sapp.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.system.dto.MainDataBankAccountDTO;
import com.ctshk.rpc.system.dto.mian.data.MainDataSubjectDTO;
import com.ctshk.rpc.system.req.MainDataBankAccountListReq;
import com.ctshk.rpc.system.req.main.data.MainDataSubjectAddReq;
import com.ctshk.rpc.system.req.main.data.MainDataSubjectListReq;
import com.ctshk.rpc.system.service.IMainDataSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 主数据 - 科目 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-06-22
 */
@Api(value = "主數據-科目",tags = "主數據-科目")
@RestController
@RequestMapping("/main-data-subject")
public class MainDataSubjectController extends BaseController {

    @DubboReference
    private IMainDataSubjectService service;

    /**
     * 科目列表
     * @param req
     * @return
     */
    @ApiOperation(value="列表", notes="科目列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "科目列表", operDesc = "科目列表")
    @PostMapping("/list")
    public Result<PageResponse<MainDataSubjectDTO>> list(@RequestBody @Valid MainDataSubjectListReq req){
        return Result.success(service.list(req));
    }

    /**
     * 新增/修改
     * @param req
     * @return
     */
    @ApiOperation(value="新增/修改", notes="新增/修改 科目")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "新增/修改 科目", operDesc = "新增/修改 科目")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataSubjectAddReq req){
        return service.add(req,getCurrentUser(getRequest()).getId());
    }

    /**
     * 详情
     */
    @ApiOperation(value="详情", notes="科目详情")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "科目详情", operDesc = "科目详情")
    @GetMapping("/detail/{id}")
    public Result<MainDataSubjectDTO> detail(@PathVariable Long id){
        return service.detail(id);
    }

    /**
     * 修改状态
     */
    @ApiOperation(value="修改状态", notes="科目修改状态")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "科目修改状态", operDesc = "科目修改状态")
    @GetMapping("/status/{id}")
    public Result status(@PathVariable Long id){
        return service.status(id,getCurrentUser(getRequest()).getId());
    }

    /**
     * 删除
     */
    @ApiOperation(value="删除", notes="删除科目")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "删除科目", operDesc = "删除科目")
    @GetMapping("/del/{id}")
    public Result del(@PathVariable Long id){
        return service.del(id,getCurrentUser(getRequest()).getId());
    }

}
